package com.atguigu.gulimail.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.client.RedisClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Fengkai
 * @creat 2022/3/6
 */
@Configuration
public class RedissonConfig {

    @Value("${spring.redis.host:192.168.157.128}")
    private String redisUrl;

    @Value("${spring.redis.port:6379}")
    private String redisPort;


    @Bean("redissonClient")
    public RedissonClient getRedissonclient () {
        String baseUrl = "redis://" + redisUrl + ":" + redisPort;
        Config config = new Config();
        config.useSingleServer().setAddress(baseUrl);
        config.setLockWatchdogTimeout(30);
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}
